//package com.kungfuhacking.wristbandpro.find.activity;
//
//import android.os.Bundle;
//import android.support.v7.widget.DefaultItemAnimator;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.text.TextUtils;
//import android.view.View;
//
//import com.kungfuhacking.wristbandpro.R;
//import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
//import com.kungfuhacking.wristbandpro.custom.TitleBarView;
//import com.kungfuhacking.wristbandpro.find.bean.OrderInfo;
//import com.kungfuhacking.wristbandpro.find.presenter.IOrderListPresenter;
//import com.kungfuhacking.wristbandpro.find.presenter.OrderHistoryAdapter;
//import com.kungfuhacking.wristbandpro.find.view.IOrderListView;
//import com.kungfuhacking.wristbandpro.utils.LogUtil;
//import com.kungfuhacking.wristbandpro.widget.swipe.DividerItemDecoration;
//import com.kungfuhacking.wristbandpro.widget.swipe.OnItemClickListener;
//
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 订单列表
// * Created by Aaron on 17/5/10.
// */
//
//public class OrderListActivity extends BaseActivity implements IOrderListView {
//
//    private RecyclerView recycleView;
//    private IOrderListPresenter iOrderListPresenter = new IOrderListPresenter(this);
//    private List<OrderInfo> orderInfoList = new ArrayList<>();
//    private OrderHistoryAdapter orderHistoryAdapter;
//    private String TAG = getClass().getSimpleName();
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//
//        setContentView(R.layout.activity_order_list);
//        initWiget();
//        iOrderListPresenter.getOrderList();
//    }
//
//    private void initWiget() {
//        this.recycleView = (RecyclerView) findViewById(R.id.rcv);
//        TitleBarView tbv = (TitleBarView) findViewById(R.id.tbv);
//        tbv.setOnLeftClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                finish();
//            }
//        });
//        initRecycleView();
//    }
//
//    private void initRecycleView() {
//
//        recycleView.setLayoutManager(new LinearLayoutManager(this));
//        recycleView.setItemAnimator(new DefaultItemAnimator());
//        orderHistoryAdapter = new OrderHistoryAdapter(this, orderInfoList);
//        recycleView.setAdapter(orderHistoryAdapter);
//        recycleView.addItemDecoration(new DividerItemDecoration(this,
//                DividerItemDecoration.VERTICAL_LIST,
//                getResources().getDrawable(R.color.bg_gray)));
//        recycleView.addOnItemTouchListener(new OnItemClickListener(recycleView) {
//            @Override
//            public void onItemClick(RecyclerView.ViewHolder holder, int position) {
//
//                if (orderInfoList.get(position).getTradeState().equals("SUCCESS")) {
//                    //详情页面
//                    LogUtil.d(TAG, "详情页面 : " + orderInfoList.get(position).getSubject());
//                    try {
//                        JSONObject jsonObject = new JSONObject(orderInfoList.get(position).getBody());
//                        Bundle b = new Bundle();
//                        if (TextUtils.isEmpty(jsonObject.getString("address"))) {//充值订单, 查看详情
//                            String phoneNum = jsonObject.getString("phoneNum");
//                            LogUtil.d(TAG, "这是充值 订单,手机号码:" + phoneNum);
//                            b.putString("phoneNum", phoneNum);
//                            nextActivityWithBundle(OrderDetailActivity.class, b);
//
//                        } else {
//
//                            String tradeNo = orderInfoList.get(position).getTradeNo();//订单号
//                            LogUtil.d(TAG, "这是新开卡 订单 : " + tradeNo);
//                            b.putString("tradeNo", tradeNo);
//                            nextActivityWithBundle(LogisticsActivity.class, b);
//
//                        }
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//
//            @Override
//            public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
//
//            }
//        });
//    }
//
//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//        iOrderListPresenter.clearRequest();
//    }
//
//    @Override
//    public void setAdapterData(List<OrderInfo> orderInfoList) {
//        this.orderInfoList = orderInfoList;
//        orderHistoryAdapter.setOrderInfoList(orderInfoList);
//        orderHistoryAdapter.notifyDataSetChanged();
//    }
//}
